package com.ruoyi.web.controller.commerce;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.commerce.domain.CommerceInfoFac;
import com.ruoyi.commerce.service.ICommerceInfoFacService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 帮养之家和设施用品关联Controller
 *
 * @author zhezhi
 * @date 2022-10-03
 */
@RestController
@RequestMapping("/commerce/info_fac")
public class CommerceInfoFacController extends BaseController
{
    @Autowired
    private ICommerceInfoFacService commerceInfoFacService;

    /**
     * 查询帮养之家和设施用品关联列表
     */
    @PreAuthorize("@ss.hasPermi('commerce:info_fac:list')")
    @GetMapping("/list")
    @ApiOperation("查询帮养之家和设施用品关联列表")
    public TableDataInfo list(CommerceInfoFac commerceInfoFac)
    {
        startPage();
        List<CommerceInfoFac> list = commerceInfoFacService.selectCommerceInfoFacList(commerceInfoFac);
        return getDataTable(list);
    }

    /**
     * 导出帮养之家和设施用品关联列表
     */
    @PreAuthorize("@ss.hasPermi('commerce:info_fac:export')")
    @Log(title = "帮养之家和设施用品关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出帮养之家和设施用品关联列表")
    public void export(HttpServletResponse response, CommerceInfoFac commerceInfoFac)
    {
        List<CommerceInfoFac> list = commerceInfoFacService.selectCommerceInfoFacList(commerceInfoFac);
        ExcelUtil<CommerceInfoFac> util = new ExcelUtil<CommerceInfoFac>(CommerceInfoFac.class);
        util.exportExcel(response, list, "帮养之家和设施用品关联数据");
    }

    /**
     * 获取帮养之家和设施用品关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('commerce:info_fac:query')")
    @GetMapping(value = "/{infoId}")
    @ApiOperation("获取帮养之家和设施用品关联详细信息")
    public AjaxResult getInfo(@PathVariable("infoId") Long infoId)
    {
        return AjaxResult.success(commerceInfoFacService.selectCommerceInfoFacByInfoId(infoId));
    }

    /**
     * 新增帮养之家和设施用品关联
     */
    @PreAuthorize("@ss.hasPermi('commerce:info_fac:add')")
    @Log(title = "帮养之家和设施用品关联", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增帮养之家和设施用品关联")
    public AjaxResult add(@RequestBody CommerceInfoFac commerceInfoFac)
    {
        return toAjax(commerceInfoFacService.insertCommerceInfoFac(commerceInfoFac));
    }

    /**
     * 修改帮养之家和设施用品关联
     */
    @PreAuthorize("@ss.hasPermi('commerce:info_fac:edit')")
    @Log(title = "帮养之家和设施用品关联", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改帮养之家和设施用品关联")
    public AjaxResult edit(@RequestBody CommerceInfoFac commerceInfoFac)
    {
        return toAjax(commerceInfoFacService.updateCommerceInfoFac(commerceInfoFac));
    }

    /**
     * 删除帮养之家和设施用品关联
     */
    @PreAuthorize("@ss.hasPermi('commerce:info_fac:remove')")
    @Log(title = "帮养之家和设施用品关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{infoIds}")
    @ApiOperation("删除帮养之家和设施用品关联")
    public AjaxResult remove(@PathVariable Long[] infoIds)
    {
        return toAjax(commerceInfoFacService.deleteCommerceInfoFacByInfoIds(infoIds));
    }
}
